package com.hk.controller;

import cn.hutool.json.JSONUtil;
import com.hk.core.Result;
import com.hk.core.roleResult.PageRoleResult;
import com.hk.domain.Report;
import com.hk.dto.ClueBusinContractDto;
import com.hk.dto.ContractCXDto;
import com.hk.service.ClueService;
import com.hk.service.ContractService;
import com.hk.vo.ClueagsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;

@RestController
@RequestMapping("/report")
public class ReportController {
    @Autowired
    private ClueService clueService;
    @Autowired
    private ContractService contractService;
//统计线索
    @GetMapping("/cluesStatistics/{beginTime}/{endTime}")
public Report reports(@PathVariable LocalDate beginTime, @PathVariable LocalDate endTime){


    return clueService.getReport(beginTime,endTime);
}
//统计分页线索
@GetMapping("/cluesStatisticsList")
public PageRoleResult listClueReport(ClueBusinContractDto clueBusinContractDto){


    return clueService.listReport(clueBusinContractDto);
}
/*@GetMapping("/getVulnerabilityMap/{beginTime}/{endTime}")
public Result TjClus(@PathVariable LocalDateTime beginTime,@PathVariable LocalDateTime endTime){
        ClueagsVo clueagsVo = clueService.Tjclus(beginTime,endTime);
        return Result.success(clueagsVo);
}*/
    //统计合同分页
String JSON="{\n" +
        "    \"total\": 112,\n" +
        "    \"rows\": [\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2022-03-11 16:23:24\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"161660455985000\",\n" +
        "            \"contractNo\": \"HT11120\",\n" +
        "            \"phone\": \"15120132111\",\n" +
        "            \"name\": \"李师师\",\n" +
        "            \"subject\": \"1\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 113,\n" +
        "            \"courseId\": 47,\n" +
        "            \"status\": \"4\",\n" +
        "            \"fileName\": \"/huike-crm/2022/03/11/46aba7e8401749c5bf19ae58e7ac241c.pdf\",\n" +
        "            \"coursePrice\": 1888.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 188.8,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": null,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"shangji1\",\n" +
        "            \"createTime\": \"2021-11-24 11:29:21\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"58966242729300\",\n" +
        "            \"contractNo\": \"HTBH001\",\n" +
        "            \"phone\": \"15011111111\",\n" +
        "            \"name\": \"李凯\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 110,\n" +
        "            \"courseId\": 50,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/24/3495e72a-0f0d-4cda-a013-56ba01c3c0ac.pdf\",\n" +
        "            \"coursePrice\": 10.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 0.85,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3412,\n" +
        "            \"deptId\": 214\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"shangji\",\n" +
        "            \"createTime\": \"2021-11-22 10:42:49\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"15289471469979914\",\n" +
        "            \"contractNo\": \"CZHT001\",\n" +
        "            \"phone\": \"13811111781\",\n" +
        "            \"name\": \"韩无聊\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 71,\n" +
        "            \"courseId\": 28,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/22/fbe20477-206c-4d81-a116-f7f7d711c91b.pdf\",\n" +
        "            \"coursePrice\": 8000.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 64.0,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3403,\n" +
        "            \"deptId\": 213\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-19 11:18:09\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"15032392169585970\",\n" +
        "            \"contractNo\": \"HT0090\",\n" +
        "            \"phone\": \"13811111399\",\n" +
        "            \"name\": \"李和\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 71,\n" +
        "            \"courseId\": 28,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/19/991e5d69-4db7-4d4a-8657-3ef359afa5ad.pdf\",\n" +
        "            \"coursePrice\": 8000.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 64.0,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3391,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-16 16:36:54\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"14792316828689838\",\n" +
        "            \"contractNo\": \"ht123890\",\n" +
        "            \"phone\": \"13811111410\",\n" +
        "            \"name\": \"李口渴\",\n" +
        "            \"subject\": \"3\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 67,\n" +
        "            \"courseId\": 17,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/16/fbc52237-0257-4bcc-a298-c110aefe6852.pdf\",\n" +
        "            \"coursePrice\": 2220.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 6.66,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3402,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-16 16:20:46\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"14791349183802472\",\n" +
        "            \"contractNo\": \"ht0001\",\n" +
        "            \"phone\": \"13811111398\",\n" +
        "            \"name\": \"张夏天\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 69,\n" +
        "            \"courseId\": 32,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/16/e04cc4c3-fc74-4eca-aa89-036209ad0760.pdf\",\n" +
        "            \"coursePrice\": 10005.0,\n" +
        "            \"discountType\": \"代金券\",\n" +
        "            \"order\": 9005.0,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3390,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-16 16:20:06\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"14791309047420058\",\n" +
        "            \"contractNo\": \"hc0004\",\n" +
        "            \"phone\": \"13811111397\",\n" +
        "            \"name\": \"王红军\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 67,\n" +
        "            \"courseId\": 30,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/16/fbc02f6f-f5d1-4963-822a-7b775be2ca15.pdf\",\n" +
        "            \"coursePrice\": 10000.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 30.0,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3389,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-16 16:18:53\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"14791236266694335\",\n" +
        "            \"contractNo\": \"hc0003\",\n" +
        "            \"phone\": \"13811111409\",\n" +
        "            \"name\": \"李口渴\",\n" +
        "            \"subject\": \"1\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 66,\n" +
        "            \"courseId\": 47,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/16/f02303db-7b78-49dc-bbf6-66d93c8ffa7c.pdf\",\n" +
        "            \"coursePrice\": 1888.0,\n" +
        "            \"discountType\": \"代金券大于原课程50%,代金券不可用\",\n" +
        "            \"order\": 1888.0,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3401,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-16 16:18:00\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"14791182649481725\",\n" +
        "            \"contractNo\": \"hc0002\",\n" +
        "            \"phone\": \"13811111408\",\n" +
        "            \"name\": \"陈无\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 35,\n" +
        "            \"courseId\": 32,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/16/9aa7d6fb-5e7c-4806-9d71-25e3646857c2.pdf\",\n" +
        "            \"coursePrice\": 10005.0,\n" +
        "            \"discountType\": \"课程折扣\",\n" +
        "            \"order\": 20.01,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3400,\n" +
        "            \"deptId\": 103\n" +
        "        },\n" +
        "        {\n" +
        "            \"createBy\": \"admin\",\n" +
        "            \"createTime\": \"2021-11-16 16:17:29\",\n" +
        "            \"updateBy\": null,\n" +
        "            \"updateTime\": null,\n" +
        "            \"id\": \"14791151933839882\",\n" +
        "            \"contractNo\": \"hc0001\",\n" +
        "            \"phone\": \"13811111407\",\n" +
        "            \"name\": \"陈人\",\n" +
        "            \"subject\": \"0\",\n" +
        "            \"channel\": \"0\",\n" +
        "            \"activityId\": 34,\n" +
        "            \"courseId\": 48,\n" +
        "            \"status\": \"7\",\n" +
        "            \"fileName\": \"/profile/upload/2021/11/16/da87fa2b-f288-41b9-a073-54983f444fe5.pdf\",\n" +
        "            \"coursePrice\": 9999.0,\n" +
        "            \"discountType\": \"代金券大于原课程50%,代金券不可用\",\n" +
        "            \"order\": 9999.0,\n" +
        "            \"finishTime\": null,\n" +
        "            \"businessId\": 3399,\n" +
        "            \"deptId\": 103\n" +
        "        }\n" +
        "    ],\n" +
        "    \"code\": 200,\n" +
        "    \"msg\": \"查询成功\",\n" +
        "    \"params\": null\n" +
        "}";

private String JS="{\n" +
        "    \"xAxis\": [\n" +
        "        \"2025-05-31\",\n" +
        "        \"2025-06-01\",\n" +
        "        \"2025-06-02\",\n" +
        "        \"2025-06-03\",\n" +
        "        \"2025-06-04\",\n" +
        "        \"2025-06-05\",\n" +
        "        \"2025-06-06\",\n" +
        "        \"2025-06-07\"\n" +
        "    ],\n" +
        "    \"series\": [\n" +
        "        {\n" +
        "            \"name\": \"新增客户数\",\n" +
        "            \"data\": [\n" +
        "                17,\n" +
        "                13,\n" +
        "                10,\n" +
        "                3,\n" +
        "                11,\n" +
        "                18,\n" +
        "                13,\n" +
        "                11\n" +
        "            ]\n" +
        "        },\n" +
        "        {\n" +
        "            \"name\": \"客户总数\",\n" +
        "            \"data\": [\n" +
        "                0,\n" +
        "                17,\n" +
        "                20,\n" +
        "                30,\n" +
        "                27,\n" +
        "                25,\n" +
        "                21,\n" +
        "                11\n" +
        "            ]\n" +
        "        }\n" +
        "    ]\n" +
        "}";

@GetMapping("/contractStatisticsList")
    public String listContractReport(ContractCXDto cxDto){


      //  return  contractService.listContractReport(cxDto);
    return JSONUtil.toJsonStr(JSON);
    }

@GetMapping("/contractStatistics/{beginTime}/{endTime}")
    public String TJ(){
    return JSONUtil.toJsonStr(JS);
    }

}
